package ru.ifmo.rybakov.muclumon.msvs.proxy;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MSVSProxyPollingDaemonServletContextListener implements
		ServletContextListener {

	private static final Logger logger = LoggerFactory.getLogger(MSVSProxyPollingDaemonServletContextListener.class);
	private  MSVSProxyPollingDaemon daemon;
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		daemon.stop();
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		logger.debug("Starting MSVS proxy polling daemon...");
		daemon = new MSVSProxyPollingDaemon();
		daemon.start();
		logger.info("MSVS proxy polling daemon was successfully started");
	}

}
